﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class adminmain : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null != Session["adminName"])
            {
                Label1.Text = Session["adminName"].ToString();
                DAL.AdminDAL adminDAL = (DAL.AdminDAL)DALFAC.DataAccess.CreateAdmin();


                if (null != adminDAL )
                {
                    Model.Admin adminModel = adminDAL.GetModelByName(Session["adminName"].ToString());
                    int adminId = adminModel.getAD_adminId();
                    Session["adminId"] = adminId;
                    Label2.Text = adminModel.getAD_lastLoginTime().ToString();
                    Label3.Text = adminModel.getAD_lastLoginIP();
                }
            }
            else {
                Response.Redirect("AdminLogin.aspx");
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            string adminName = Session["adminName"].ToString();
            string url = "manage.aspx?adminName=" + adminName;
            Response.Redirect(url);
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            string adminName = Session["adminName"].ToString();
            string url = "Card.aspx?adminName=" + adminName;
            Response.Redirect(url);
        }
    }
}